package com.kgc.controller;

import com.kgc.pojo.Discount;
import com.kgc.service.DiscountService;
import com.kgc.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@RestController
public class DiscountController {
    @Autowired
    DiscountService discountService;
    /*优惠券信息获取*/
    @RequestMapping("getDiscountInfoList_yuan")
    public Object getDiscountInfoList(Integer statusId,Integer userId){
        List<Discount> discountList = discountService.getDiscountInfoList(statusId,userId);
        //System.out.println(discountList.get(1).getDiscountdetail());
        return new Result(discountList,"获取优惠券信息成功");
    }
    /*输入优惠券号码添加优惠券*/
    @RequestMapping("addDiscount_yuan")
    public Object addDiscount(String discountNum){
        List<Discount> list = discountService.addDiscount(discountNum);
        if (list.size()==0){
            return new Result(list.size(),"获取discount列表失败");//该优惠券不可用
        }
        return new Result(list,"discount列表成功");
    }
}
